<template>
  <div class="flex-x w100">
    <el-form :model="form" ref="form" :inline="true" size="small">
      <el-form-item label="制造单元" class="dark_theme">
        <el-select
          size="mini"
          v-model="form.manufactureSite"
          placeholder="请选择"
          clearable
          filterable
          class="dark_input"
        >
          <el-option
            v-for="item in manufactureSiteList"
            :key="item.name"
            :label="item.name"
            :name="item.name"
            :value="item.name"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备名称" class="dark_theme">
        <el-select
          class="dark_input"
          size="mini"
          v-model="form.deviceName"
          placeholder="请选择"
          clearable
          filterable
        >
          <el-option
            v-for="item in deviceData"
            :key="item.token"
            :label="item.name"
            :value="item.token"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="时间">
        <div class="flex-x">
          <el-date-picker
            style="margin-right: 20px;"
            class="w100 dark_input"
            v-model="dataPicker"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            align="right"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['12:00:00', '08:00:00']"
            size="mini"
          >
          </el-date-picker>
        </div>
        <!-- <el-date-picker
          class="dark_input"
          size="mini"
          v-model="form.dateVal"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker> -->
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="small" @click="onSubmit"
          >查 询</el-button
        >
        <el-button size="small" @click="handleReset">重 置</el-button>
      </el-form-item>
    </el-form>

    <!-- <div class="flex-x">
      <el-button type="primary" size="small">搜索</el-button>
      <el-button size="small">重置</el-button>
    </div> -->
  </div>
</template>

<script>
import { currentDate3 } from "@/utils/currentDate";
import { mapGetters } from "vuex";
export default {
  props: {
    deviceData: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    ...mapGetters(["manufactureSiteList"])
  },
  data() {
    return {
      deviceOptions: [],
      dataPicker: [],
      form: {
        manufactureSite: "",
        deviceName: "",
        startDate: "",
        endDate: ""
      }
    };
  },
  methods: {
    onSubmit() {
      // this.$emit("onSubmit", {
      //   ...this.form,
      //   startDate: this.form.startDate,
      //   endDate: this.form.endDate
      // });
      this.$emit("onSubmit", {
        ...this.form,
        startDate: this.dataPicker.length ? this.dataPicker[0] : "",
        endDate: this.dataPicker.length ? this.dataPicker[1] : ""
      });
    },
    handleReset() {
      Object.assign(this.$data.form, this.$options.data().form);
      this.dataPicker = [];
      this.$emit("onSubmit");
    }
  }
};
</script>
<style lang="scss" scoped></style>
